/**
 * Candidate number: 35834
 */
package tv.starfu.game.states;

import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.asset.AssetManager;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.input.InputManager;
import com.jme3.math.ColorRGBA;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;
import com.jme3.system.AppSettings;

public class PauseState extends AbstractAppState implements AppState {
    
    private AssetManager assetManager;
    private Node localRootNode = new Node("PauseRootNode");
    private Node localGuiNode = new Node("PauseGuiNode");
    private Node rootNode;
    private Node guiNode;
    private ViewPort viewport;
    private InputManager inputManager;
    private AppSettings settings;
    
    /**
     * New Paused state
     * @param app
     * @param settings 
     */
    public PauseState(SimpleApplication app, AppSettings settings) {
        this.guiNode       = app.getGuiNode();
        this.rootNode      = app.getRootNode();
        this.assetManager  = app.getAssetManager();
        this.inputManager  = app.getInputManager();
        this.viewport      = app.getViewPort();
        this.settings      = settings;
    }

    @Override
    public void initialize(AppStateManager stateManager, Application app) {
        super.initialize(stateManager, app);
        BitmapText text = drawHUD();
    }
    
        public BitmapText drawHUD() {
        BitmapFont guiFont = assetManager.loadFont(
                "Interface/Fonts/Default.fnt");
        BitmapText displaytext = new BitmapText(guiFont);
        displaytext.setSize(guiFont.getCharSet().getRenderedSize());
        displaytext.move(10, displaytext.getLineHeight() + 20, 0);
        displaytext.setColor(ColorRGBA.Blue);
        displaytext.setText("PAUSED.");
        localGuiNode.attachChild(displaytext);
        return displaytext;
  }

        
        @Override
        public void cleanup() {
            super.cleanup();
            guiNode.detachChild(localGuiNode);
            rootNode.detachChild(localRootNode);
        }

        @Override
        public void setEnabled(boolean enabled) {
            super.setEnabled(enabled);
            if(enabled){
                guiNode.attachChild(localGuiNode);
                rootNode.attachChild(localRootNode);
          }
        }
}
